﻿using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections;
using System;

namespace ugui.demo1
{

    public class pointerPressRaycast : MonoBehaviour,
        IPointerUpHandler,
        IPointerDownHandler,
        IBeginDragHandler,
        IEndDragHandler

    {


        
        public void OnPointerUp(PointerEventData eventData)
        {
            //点击发射的射线，hit的物体 go不为空
            GameObject go = eventData.pointerPressRaycast.gameObject;

            if (go != null)
            {
                Debug.LogError(gameObject.name + " OnPointerUp eventData.pointerPressRaycast:" + go.name);
            }
        }


        public void OnPointerDown(PointerEventData eventData)
        {
            //点击发射的射线，hit的物体 go不为空
            GameObject go = eventData.pointerPressRaycast.gameObject;

            if (go != null)
            {
                Debug.LogError(gameObject.name + " OnPointerDown eventData.pointerPressRaycast:" + go.name);
            }
        }

        public void OnBeginDrag(PointerEventData eventData)
        {

            //点击发射的射线，hit的物体 go为空！
            GameObject go = eventData.pointerPressRaycast.gameObject;

            if (go != null)
            {
                Debug.LogError(gameObject.name + " OnBeginDrag eventData.pointerPressRaycast:" + go.name);
            }
        }

        public void OnDrag(PointerEventData eventData)
        {
            //点击发射的射线，hit的物体 go为空！
            GameObject go = eventData.pointerPressRaycast.gameObject;

            if (go != null)
            {
                Debug.LogError(gameObject.name + " OnDrag eventData.pointerPressRaycast:" + go.name);
            }
        }

        public void OnEndDrag(PointerEventData eventData)
        {
            //点击发射的射线，hit的物体 go为空！
            GameObject go = eventData.pointerPressRaycast.gameObject;

            if (go != null)
            {
                Debug.LogError(gameObject.name + " OnEndDrag eventData.pointerPressRaycast:" + go.name);
            }
        }



    }
}
